package dbTools.coeModel.modelElement.demos.demo1;

import java.util.Map;

import projectsupporter.common.logic.GlobalInfo;
import dbTools.coeModel.CodeModel;
import dbTools.coeModel.modelElement.AbstractReplaceElement;
import dbTools.coeModel.modelElement.IModelMainMethod;
import dbTools.tableInfo.info.TableInfo;

public class DemoMenu1 extends AbstractReplaceElement implements IModelMainMethod {


	@Override
	public String getFileName(TableInfo tableInfo) {
		return "menu.jsp";
	}

	@Override
	public String getFilePath(TableInfo tableInfo) {
		return GlobalInfo.PRJ_NAME+"/WebRoot/menu";
	}

	@Override
	public void doMainMethod(CodeModel codeModel,Map<String, TableInfo> tableInfos) {
		if(isCopySus(codeModel, null) == false)
		{
			return;
		}
		
		file.replaceTxtByStr("<##MAINCODE##>", getMainCode(tableInfos));
		
	}

	private String getMainCode(Map<String, TableInfo> tableInfos) {
		StringBuffer code=new StringBuffer();
		for (Map.Entry<String, TableInfo> entry : tableInfos.entrySet()) 
		{
			code.append("<a href='http://localhost:28080/"+GlobalInfo.PRJ_NAME+"/master/"+entry.getValue().getTableId().toLowerCase()+"Mst.do' >"+entry.getValue().getTableName()+"</a><br />\r\n");
		}
		return code.toString();
	}
}
